﻿/*
Constants for ReadingColumnIndices
*/
var READINGID_COL_INDEX = 0;
var USERVEHICLE_ID_COL_INDEX = 1;
var ODOMETER_COL_INDEX = 2;
var FUELADDED_COL_INDEX = 3;
var FUELPRICE_COL_INDEX = 4;
var LATTITUDE_COL_INDEX = 5;
var LONGITUDE_COL_INDEX = 6;
var DISTANCECOVERED_COL_INDEX = 7;
var FUELEFFICIENCY_COL_INDEX = 8;
var COSTPERFUELUNIT_COL_INDEX = 9;
var TIMESTAMP__COL_INDEX = 10;
var VEHICLENAME_COL_INDEX = 11;
/*
This javascript gets all user readings. 
*/
function getUserReadings(userVehicleId,successCB, failCB) {
    var url = "../../Reading/GetUserReadingsByVehicleID";
    if (window.navigator.userAgent.toLowerCase().indexOf('iphone') == -1 || window.navigator.userAgent.toLowerCase().indexOf('android') == -1) {
        //non mobile device
        url = "../Reading/GetUserReadingsByVehicleID";
    }
    
    
    $.ajax({
        type: "GET",
        url: url,  
        data:{userVehicleId:userVehicleId},     
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: successCB,
        error: failCB
    })
}

function getAllReadingsForUser(successCB, failCB) {
    var url = "../../Reading/GetUserReadings";
    if (window.navigator.userAgent.toLowerCase().indexOf('iphone') == -1 && window.navigator.userAgent.toLowerCase().indexOf('android') == -1) {
        //non mobile device
        url = "../Reading/GetUserReadings";
    }
    
    
    $.ajax({
        type: "GET",
        url: url,
        //data: { userVehicleId: userVehicleId },
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: successCB,
        error: failCB
    })
}
